{* Вкладка СЧЕТА *}

{* Подключаем окно редактирования счета *}
{include file="admin/submodules/invoice.dialog.html"}

<div class="tabs" id="invoiceTabs">
    <ul>
	{foreach from=$executives item=executive}
	<li><a href="#invoice-from-executive-id{$executive.id}">{$executive.executive_name|sslash}</a></li>
	{/foreach}
    </ul>

    {foreach from=$executives item=executive}
<!-- Под-ВКЛАДКА {$executive.executive_name} -->
    <div id="invoice-from-executive-id{$executive.id}">
	<table class="ui-widget" cellspacing="0" rules="all" width="80%" style="border: solid 1px #000000;">
	    <thead class="ui-widget-header">
		<tr>
		    <th rowspan="2">Дата</th>
		    <th rowspan="2">Номер</th>
		    <th colspan="4">Документ</th>
		    <th rowspan="2">&nbsp;</th>
		</tr>
		<tr>
		    <th>Счет</th>
		    <th>Акт</th>
		    <th>Счет-фактура</th>
		    <th>Детализация</th>
		</tr>
	    </thead>

	    <tbody class="ui-widget-content">
	    {foreach from=$invoices[$executive.id] item=invoice}
		<tr>
		    <td>{$invoice.date|date_format:'%d.%m.%Y'}</td>
		    <td>{$invoice.id}</td>
		    {if $invoice.status==1}
		    <td align="center">{if $invoice.account}<a href="files/{$invoice.account}?rand={1|rand:99999}" target="_blank">Скачать</a>{else}&mdash;{/if}</td>
		    <td align="center">{if $invoice.act}<a href="files/{$invoice.act}?rand={1|rand:99999}" target="_blank">Скачать</a>{else}&mdash;{/if}</td>
		    <td align="center">{if $invoice.invoice}<a href="files/{$invoice.invoice}?rand={1|rand:99999}" target="_blank">Скачать</a>{else}&mdash;{/if}</td>
		    <td align="center">{if $invoice.detail}<a href="files/{$invoice.detail}?rand={1|rand:99999}" target="_blank">Скачать</a>{else}&mdash;{/if}</td>
		    {else}
		    <td colspan="4"><i>документы будут готовы в ближайшее время</i></td>
		    {/if}
		    <td align="center">
			<a href="invoice-delete.php?id={$invoice.id}" class="invoice-delete" title="Удалить"><img src="images/icons/delete_16.png" alt="Удалить"/></a>
			<a href="invoice-remake.php?id={$invoice.id}" class="invoice-remake" title="Перевыставить"><img src="images/icons/refresh_16.png" alt="Перевыставить"/></a>
		    </td>
		</tr>
	    {foreachelse}
		<tr><td align="center" colspan="7"><i>документы не созданы</i></td></tr>
	    {/foreach}
	    </tbody>
	</table>
{*
	<br/>
	<a href="doc-print.php?type=akt&executive_id={$executive.id}&account_id={$customer.account_id}" target="_blank">Получить бланк Акта</a><br/>
	<a href="doc-print.php?type=invoice&executive_id={$executive.id}&account_id={$customer.account_id}" target="_blank">Получить бланк Счёта</a>
*}
    </div>
    {/foreach}

{*
<!-- Под-ВКЛАДКА Счета-ТТК -->
    <div id="invoice-rtk">
	<table class="ui-widget" cellspacing="0" rules="all" style="border: solid 1px #000000;">
	    <thead class="ui-widget-header">
		<tr>
		    <th>Дата</th>
		    <th>Номер</th>
		    <th>Название документа</th>
		    <th>Файл</th>
		    <th>&nbsp;</th>
		</tr>
	    </thead>

	    <tbody class="ui-widget-content">
	    {foreach from=$docs_rtk item=doc}
	    {assign var="mime" value=$doc.filename|regex_replace:'/.+\.(.+)$/':'$1'|lower}
		<tr>
		    <td>{$doc.document_date|date_format:'%d.%m.%Y'}</td>
		    <td>{$doc.document_num}</td>
		    <td>{$doc.document_name}</td>
		    <td>
			<a href="/cgi-bin/dl.cgi?id={$doc.id}">
			    {if $mime=='jpg' || $mime=='gif' || $mime=='png' || $mime=='bmp'}
			<img src="images/icons/mimetypes/image.png" border="0"/>
			    {elseif $mime=='pdf'}
			<img src="images/icons/mimetypes/pdf-document.png" border="0"/>
			    {elseif $mime=='txt'}
			<img src="images/icons/mimetypes/txt.png" border="0"/>
			    {else}
			<img src="images/icons/mimetypes/unknown.png" border="0"/>
			    {/if}
			{$doc.filename}
			</a>
			<i>({math equation='x/1024' x=$doc.size format='%0.2f'} КБ)</i>
		    </td>
		    <td align="center"><a href="document-delete.php?id={$doc.id}"><img src="images/icons/delete_16.png" border="0" title="Удалить"/></a></td>
		</tr>
	    {foreachelse}
		<tr><td align="center" colspan="5"><i>документы не загружены</i></td></tr>
	    {/foreach}
	    </tbody>
	</table>
	<br/>
	<a href="javascript:void(0)" id="act-print-rtk">Получить бланк Акта</a><br/>
	<a href="javascript:void(0)" id="invoice-print-rtk">Получить бланк Счёта</a>
    </div>

<!-- Под-ВКЛАДКА Счета-Инлайн -->
    <div id="invoice-inline">
	<table class="ui-widget" cellspacing="0" rules="all" style="border: solid 1px #000000;">
	    <thead class="ui-widget-header">
		<tr>
		    <th>Дата</th>
		    <th>Номер</th>
		    <th>Название документа</th>
		    <th>Файл</th>
		    <th>&nbsp;</th>
		</tr>
	    </thead>
	    <tbody class="ui-widget-content">
	    {foreach from=$docs_inline item=doc}
	    {assign var="mime" value=$doc.filename|regex_replace:'/.+\.(.+)$/':'$1'|lower}
		<tr>
		    <td>{$doc.document_date|date_format:'%d.%m.%Y'}</td>
		    <td>{$doc.document_num}</td>
		    <td>{$doc.document_name}</td>
		    <td>
			<a href="/cgi-bin/dl.cgi?id={$doc.id}">
			{if $mime=='jpg' || $mime=='gif' || $mime=='png' || $mime=='bmp'}
			    <img src="images/icons/mimetypes/image.png" border="0"/>
			{elseif $mime=='pdf'}
			    <img src="images/icons/mimetypes/pdf-document.png" border="0"/>
			{elseif $mime=='txt'}
			    <img src="images/icons/mimetypes/txt.png" border="0"/>
			{else}
			    <img src="images/icons/mimetypes/unknown.png" border="0"/>
			{/if}
			    {$doc.filename}
			</a>
			<i>({math equation='x/1024' x=$doc.size format='%0.2f'} КБ)</i>
		    </td>
		    <td align="center"><a href="document-delete.php?id={$doc.id}"><img src="images/icons/delete_16.png" border="0" title="Удалить"/></a></td>
		</tr>
	    {foreachelse}
		<tr>
		    <td align="center" colspan="5"><i>документы не загружены</i></td></tr>
	    {/foreach}
	    </tbody>
	</table>
	<br/>
	<a href="javascript:void(0)" id="act-print-inline">Получить бланк Акта</a><br/>
	<a href="javascript:void(0)" id="invoice-print-inline">Получить бланк Счёта</a>
    </div>
*}
</div>

<a href="javascript:void(0)" id="document-add-invoice"><img src="images/icons/plus_16.png" border="0"/>&nbsp;Добавить документ</a>
<br/><br/>

<div class="ui-widget {if $by_period==1}ui-state-default{else}ui-state-disabled{/if} ui-corner-all div-set-period">
    <form method="get" action="#invoice">
	<input type="hidden" name="id" value="{$customer.id}"/>
	    <center>
		<input type="checkbox" class="set-period" {if $by_period==1}checked{/if}/>
		Отображать документы {html_select_date display_days=false prefix=docStart_} по {html_select_date display_days=false prefix=docEnd_}&nbsp;<input type="submit" value="&raquo;"/>
	    </center>
    </form>
</div>
